const expect = require('chai').expect

const db = require('./classes/db')
const AppHotel = require('../classes/AppHotel')

describe('AppHotel', () => {
  const appHotel = new AppHotel()

  it('Deve registrar hoteis', () => {
    appHotel.registerHotels([
      {
        name: 'Fulano',
        rating: 3,
        rate: {
          regular: 200,
          regularWeekend: 100,
          loyalty: 100,
          loyaltyWeekend: 50
        }
      }
    ])
    const hotel = appHotel.getHotels()[0]
    expect(hotel.name).to.equal('Fulano')
  })

  it('Deve criar orçamentos apartir dos hoteis e das informações de estadia', () => {
    appHotel.registerHotels(db)
    const budgets = appHotel.createBudgets(appHotel.getHotels(), 'Regular: 16Mar2009(mon), 17Mar2009(tues), 18Mar2009(wed)')[0]
    expect(budgets).has.property('budget')
  })

  it('Deve buscar o melhor orçamento considerando melhor hotel', () => {
    const betterBudget = appHotel.searchHotelLowerPrice([
      { name: 'Hotel A', rating: 3, budget: 600 },
      { name: 'Hotel B', rating: 2, budget: 200 },
      { name: 'Hotel C', rating: 3, budget: 20 }
    ])
    expect(betterBudget.name).to.equal('Hotel C')
  })
})